import React from 'react'
import ReactEcharts from "echarts-for-react";
import * as echarts from 'echarts'
import { connect } from 'react-redux';
import { withRouter,Link } from 'react-router-dom';


class FcLine extends React.Component {
  constructor(props){
        super(props);
        this.state={
            
        };
        // this.indicator = []
  }
  componentDidMount() {
    const data = this.props.optionData
    let series=[];
    if (JSON.stringify(data) != "{}") {
      for(let i = 0;i<data.value.length;i++){
        series.push({
          type:'line',
          data:data.value[i].fc
        })
      }
    }
    var myChart = echarts.init(document.getElementById('fcLine'));
    myChart.setOption({
      title:{
        text:'fc因子'
      },
      xAxis: {
        type: 'category',
        data: data.time || [],
      },
      yAxis: {
        type: 'value'
      },
      series: series
    })
  }
  


  render(){
    const { width, height, equip } = this.props
    console.log(equip);
    return (
      <div id="fcLine" style={{width:'400px',height:'300px'}}> 
      </div>
    )
  }
}

const mapStateToProps = (state) => ({ optionData:state.equipmentPage.optionData,width:state.equipmentPage.width,height:state.equipmentPage.height,equip:state.equipmentPage.equip});
const mapDispatchToProps = dispatch => {
  return {
    getBackImg: dispatch.equipmentPage.getBackImg,
    getCurve: dispatch.equipmentPage.getCurve,
  }
};
export default connect(
    mapStateToProps,
    mapDispatchToProps
)(withRouter(FcLine));